const Router = require('koa-router')

const { register, login } = require('../controller/user.controller')
const {
    userValidator,
    verifyUser,
    crpytPassword,
    verifyLogin,
    auth
} = require('../middleware/user.middleware')

const router = new Router({ prefix: '/api/user' })

// 注册接口
router.post('/register',userValidator,verifyUser,crpytPassword, register)

// 登录接口
router.post('/login', userValidator,verifyLogin,login)

// 修改密码接口
router.patch('/', auth, async(ctx, next) => {
    console.log(ctx.state.user)
    ctx.body = '修改密码成功'
  })
module.exports = router